from utils.log import Log


class Hanoi(Log):
    def __init__(self, n_layer=3):
        super(Hanoi, self).__init__()
        self.n_layer = n_layer

    def do(self):
        if self.n_layer > 0:
            self.f(self.n_layer, "左", "右", "中")

    def f(self, n, start, end, through):
        if n == 1:
            self.info(f"移动圆盘 {n} 从 {start} 到 {end}")
        else:
            self.f(n - 1, start, through, end)
            self.info(f"移动圆盘 {n} 从 {start} 到 {end}")
            self.f(n - 1, through, end, start)


if __name__ == '__main__':
    h = Hanoi()
    h.do()
